package com.ukao.steward.util;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;

import com.ukao.steward.bean.ProductRelImgBean;
import com.ukao.steward.ui.ScanQRcodeActivity;
import com.ukao.steward.ui.SunScanActivity;
import com.ukao.steward.ui.login.LoginActivity;
import com.ukao.steward.ui.valetRunners.storage.CameraActivity;
import com.ukao.steward.ui.valetRunners.storage.PhotoListActivity;

import java.util.ArrayList;

import static com.ukao.steward.consts.Constant.ARG_PARAM1;
import static com.ukao.steward.consts.Constant.ARG_PARAM2;

/**
 * Created by ukaodev on 2017/9/14.
 */

public class ActivityUtils {

    public static void JumpToActivity(Context context, Class<?> cls) {
        Intent intent = new Intent(context, cls);
        context.startActivity(intent);
    }
    public static void JumpToBundleActivity(Context context,Bundle  mBundle, Class<?> cls) {
        Intent intent = new Intent(context, cls);
        intent.putExtras(mBundle);
        context.startActivity(intent);
    }


    /**
     * 重新登录
     */
    public static void JumpAgainActivity(Context  context) {
        Intent intent = new Intent(context, LoginActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(intent);

    }


    public static Intent JumpCameraActivity(Context  context) {
        Intent intent = new Intent(context, CameraActivity.class);

        return  intent ;
    }

    public static void JumpPhotoListActivity(Context  context, int pos, ArrayList<ProductRelImgBean>  mData) {
        Intent intent =new Intent(context,PhotoListActivity.class);
        intent.putExtra(ARG_PARAM1,mData);
        intent.putExtra(ARG_PARAM2, pos);
        context.startActivity(intent);

    }


    /**
     * 跳转扫码界面
     * @ARG_PARAM1 3
     * @return
     */
    public static Intent JumpToBundleActivity(Activity  context) {
        Intent intent=null;
        if (CheckUtils.isMIUIDevices()){
             intent = new Intent(context, SunScanActivity.class);
        }else{
             intent = new Intent(context, ScanQRcodeActivity.class);
            intent.putExtra(ARG_PARAM1,3);

        }
        return  intent ;
    }
    public static Intent JumpToQRcodeActivity(Activity  context) {
        Intent intent = new Intent(context, ScanQRcodeActivity.class);
        intent.putExtra(ARG_PARAM1,3);
        intent.putExtra(ARG_PARAM2,true); /*没有用到*/
        return  intent ;
    }



    public static void callActivity(Context  context,String phone) {
        try {
            Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:"+phone));
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(intent);
        }catch (Exception e){

        }

    }

}
